// 用户相关的类型定义

export interface CreateUserRequest {
  username: string;
  email: string;
  password: string;
  phone?: string;
  nickname?: string;
  gender?: 0 | 1 | 2;
  birthday?: string;
}

export interface UpdateUserRequest {
  username?: string;
  email?: string;
  phone?: string;
  nickname?: string;
  gender?: 0 | 1 | 2;
  birthday?: string;
  avatar?: string;
  status?: 0 | 1;
  levelId?: number;
  points?: number;
  balance?: number;
}

export interface UserQueryParams {
  page?: number;
  limit?: number;
  keyword?: string;
  status?: 0 | 1;
  gender?: 0 | 1 | 2;
  levelId?: number;
  startDate?: string;
  endDate?: string;
  sortBy?: 'id' | 'username' | 'email' | 'createdAt' | 'lastLoginAt' | 'points' | 'balance';
  sortOrder?: 'ASC' | 'DESC';
}

export interface UserResponse {
  id: number;
  username: string;
  email: string;
  phone?: string;
  avatar?: string;
  nickname?: string;
  gender: 0 | 1 | 2;
  genderText: string;
  birthday?: string;
  status: 0 | 1;
  statusText: string;
  levelId: number;
  points: number;
  balance: number;
  lastLoginAt?: string;
  createdAt: string;
  updatedAt: string;
}

export interface UserListResponse {
  users: UserResponse[];
  pagination: {
    page: number;
    limit: number;
    total: number;
    totalPages: number;
  };
}

// 用户地址相关类型
export interface CreateUserAddressRequest {
  receiverName: string;
  receiverPhone: string;
  province: string;
  city: string;
  district: string;
  address: string;
  postalCode?: string;
  isDefault?: 0 | 1;
}

export interface UpdateUserAddressRequest {
  receiverName?: string;
  receiverPhone?: string;
  province?: string;
  city?: string;
  district?: string;
  address?: string;
  postalCode?: string;
  isDefault?: 0 | 1;
}

export interface UserAddressResponse {
  id: number;
  userId: number;
  receiverName: string;
  receiverPhone: string;
  province: string;
  city: string;
  district: string;
  address: string;
  fullAddress: string;
  postalCode?: string;
  isDefault: 0 | 1;
  isDefaultText: string;
  createdAt: string;
  updatedAt: string;
}

export interface AddressQueryParams {
  page?: number;
  pageSize?: number;
  userId?: string;
  receiverName?: string;
  receiverPhone?: string;
  province?: string;
  city?: string;
  isDefault?: string;
}

export interface AddressListResponse {
  list: UserAddressResponse[];
  total: number;
  page: number;
  pageSize: number;
}

// 用户统计相关类型
export interface UserStatsResponse {
  totalUsers: number;
  activeUsers: number;
  inactiveUsers: number;
  newUsersToday: number;
  newUsersThisWeek: number;
  newUsersThisMonth: number;
  genderDistribution: {
    unknown: number;
    male: number;
    female: number;
  };
  levelDistribution: {
    [key: string]: number;
  };
}